

## m figures for aid rewards

## Assumes that the starting working dir is the top dir of the archive
dir.create("m_figures")
setwd("m_figures")

## Aid - ICCPR
coeff <- 1.25472
se <- .9018797
ss <- c(.02,.1,.2,.3,.4,.5)
holder <- matrix(NA, length(ss),3)
for(i in 1:length(ss)){
  holder[i,2:3]<- qnorm(p=c(1-(ss[i]/2),(ss[i]/2)),coeff, se)
  holder[i,1] <- 1-ss[i]/2
}
holder
  ## figure
pdf("aid-iccpr.pdf",4.5,4)
par(mar=c(5,4,4,1))
plot(y=holder[,1],x=holder[,2],xlim=c((min(holder[,2],0)),max(holder[,2])), 
  axes=F, xlab="Minimally meaningful aid reward\n($/capita over 6 years)",
  ylab="Confidence level",main="Aid - ICCPR (Model 1)")
segments(y0=holder[,1],y1=rep(0,length(holder[,1])),x0=holder[,2],x1=holder[,2], lty=2)
axis(1)
axis(2,at=holder[,1],labels=round(holder[,1],3), las=2)
dev.off()


## Aid - OP 1
coeff <- 1.132194
se <- .8601755
ss <- c(.02,.1,.2,.3,.4,.5)
holder <- matrix(NA, length(ss),3)
for(i in 1:length(ss)){
  holder[i,2:3]<- qnorm(p=c(1-(ss[i]/2),(ss[i]/2)),coeff, se)
  holder[i,1] <- 1-ss[i]/2
}
holder
  ## figure
pdf("aid-op1.pdf",4.5,4)
par(mar=c(5,4,4,1))
plot(y=holder[,1],x=holder[,2],xlim=c((min(holder[,2],0)),max(holder[,2])), 
  axes=F, xlab="Minimally meaningful aid reward\n($/capita over 6 years)",
  ylab="Confidence level",main="Aid - OP 1 (Model 2)")
segments(y0=holder[,1],y1=rep(0,length(holder[,1])),x0=holder[,2],x1=holder[,2], lty=2)
axis(1)
axis(2,at=holder[,1],labels=round(holder[,1],3), las=2)
dev.off()

## Aid - CAT
coeff <- 1.24521
se <- .820875
ss <- c(.02,.1,.2,.3,.4,.5)
holder <- matrix(NA, length(ss),3)
for(i in 1:length(ss)){
  holder[i,2:3]<- qnorm(p=c(1-(ss[i]/2),(ss[i]/2)),coeff, se)
  holder[i,1] <- 1-ss[i]/2
}
holder
  ## figure
pdf("aid-cat.pdf",4.5,4)
par(mar=c(5,4,4,1))
plot(y=holder[,1],x=holder[,2],xlim=c((min(holder[,2],0)),max(holder[,2])), 
  axes=F, xlab="Minimally meaningful aid reward\n($/capita over 6 years)",
  ylab="Confidence level",main="Aid - CAT (Model 3)")
segments(y0=holder[,1],y1=rep(0,length(holder[,1])),x0=holder[,2],x1=holder[,2], lty=2)
axis(1)
axis(2,at=holder[,1],labels=round(holder[,1],3), las=2)
dev.off()


## Aid - Art22
coeff <- -.6616932
se <- .7870383 
ss <- c(.02,.1,.2,.3,.4,.5)
holder <- matrix(NA, length(ss),3)
for(i in 1:length(ss)){
  holder[i,2:3]<- qnorm(p=c(1-(ss[i]/2),(ss[i]/2)),coeff, se)
  holder[i,1] <- 1-ss[i]/2
}
holder
  ## figure
pdf("aid-art22.pdf",4.5,4)
par(mar=c(5,4,4,1))
plot(y=holder[,1],x=holder[,2],xlim=c((min(holder[,2],0)),max(holder[,2])), 
  axes=F, xlab="Minimally meaningful aid reward\n($/capita over 6 years)",
  ylab="Confidence level",main="Aid - Art. 22 (Model 4)")
segments(y0=holder[,1],y1=rep(0,length(holder[,1])),x0=holder[,2],x1=holder[,2], lty=2)
axis(1)
axis(2,at=holder[,1],labels=round(holder[,1],3), las=2)
dev.off()

## Then use photoshop to convert to png

#############################################################

## PTA - ICCPR
sig <- c(.99,.95,.90,.85,.80,.75)
holder <- matrix(c(.0105405,.0399464,
                   .0143153,.0358681,
                   .0162703,.0334048,
                   .0178783,.0316059,
                   .0190525,.0302764,
                   .0198952,.0290782),6,2,byrow=T)
holder
holder <- cbind(sig,holder[,2]*100,holder[,1]*100)

holder
  ## figure
pdf("pta-iccpr.pdf",4.5,4)
par(mar=c(5,4,4,1))
plot(y=holder[,1],x=holder[,2],xlim=c((min(holder[,2],0)),max(holder[,2])), 
  axes=F, xlab="Minimally meaningful PTA reward\n(percentage point increase in probability of signing)",
  ylab="Confidence level",main="PTA - ICCPR (Model 5)")
segments(y0=holder[,1],y1=rep(0,length(holder[,1])),x0=holder[,2],x1=holder[,2], lty=2)
axis(1)
axis(2,at=holder[,1],labels=round(holder[,1],3), las=2)
dev.off()


## PTA - OP1
sig <- c(.99,.95,.90,.85,.80,.75)
holder <- matrix(c(-.0084284,    .0154124,
                   -.0051843,    .0109872,
                   -.0036233,     .009714,
                   -.0028559,    .0083096,
                   -.0018088,    .0071674,
                   -.0010453,    .0062725),6,2,byrow=T)
holder
holder <- cbind(sig,holder[,2]*100,holder[,1]*100)

holder
  ## figure
pdf("pta-opt1.pdf",4.5,4)
par(mar=c(5,4,4,1))
plot(y=holder[,1],x=holder[,2],xlim=c((min(holder[,2],0)),max(holder[,2])), 
  axes=F, xlab="Minimally meaningful PTA reward\n(percentage point increase in probability of signing)",
  ylab="Confidence level",main="PTA - OP 1 (Model 6)")
segments(y0=holder[,1],y1=rep(0,length(holder[,1])),x0=holder[,2],x1=holder[,2], lty=2)
axis(1)
axis(2,at=holder[,1],labels=round(holder[,1],3), las=2)
dev.off()


## PTA - CAT
sig <- c(.99,.95,.90,.85,.80,.75)
holder <- matrix(c(-.0033546,    .0074646,
                   -.0020099 ,   .0056458,
                   -.0011592,    .0048213,
                   -.0007586,    .0042693,
                   -.0003208,     .003794,
                   .000102 ,   .0033765),6,2,byrow=T)
holder
holder <- cbind(sig,holder[,2]*100,holder[,1]*100)

holder
  ## figure
pdf("pta-cat.pdf",4.5,4)
par(mar=c(5,4,4,1))
plot(y=holder[,1],x=holder[,2],xlim=c((min(holder[,2],0)),max(holder[,2])), 
  axes=F, xlab="Minimally meaningful PTA reward\n(percentage point increase in probability of signing)",
  ylab="Confidence level",main="PTA - CAT (Model 7)")
segments(y0=holder[,1],y1=rep(0,length(holder[,1])),x0=holder[,2],x1=holder[,2], lty=2)
axis(1)
axis(2,at=holder[,1],labels=round(holder[,1],3), las=2)
dev.off()



## PTA - art22
sig <- c(.99,.95,.90,.85,.80,.75)
holder <- matrix(c(.0054406 ,   .0573704,
                   .0111429 ,   .0440315,
                   .0137439 ,   .0401329,
                   .0154008 ,   .0370888,
                   .0170575 ,   .0349828,
                   .0187706 ,   .0329231),6,2,byrow=T)
holder
holder <- cbind(sig,holder[,2]*100,holder[,1]*100)

holder
  ## figure
pdf("pta-art22.pdf",4.5,4)
par(mar=c(5,4,4,1))
plot(y=holder[,1],x=holder[,2],xlim=c((min(holder[,2],0)),max(holder[,2])), 
  axes=F, xlab="Minimally meaningful PTA reward\n(percentage point increase in probability of signing)",
  ylab="Confidence level",main="PTA - Art 22 (Model 8)")
segments(y0=holder[,1],y1=rep(0,length(holder[,1])),x0=holder[,2],x1=holder[,2], lty=2)
axis(1)
axis(2,at=holder[,1],labels=round(holder[,1],3), las=2)
dev.off()

#####################################################################

## BIT - ICCPR
sig <- c(.99,.95,.90,.85,.80,.75)
holder <- matrix(c(-.0603615,   -.0115769,
                   -.0482519,   -.0153202,
                   -.0431194,   -.0181458,
                   -.0394117,   -.0195144,
                   -.0370014,   -.0208592,
                   -.0351435,    -.022246),6,2,byrow=T)
holder
holder <- cbind(sig,holder[,2]*100,holder[,1]*100)

holder
  ## figure
pdf("bit-iccpr.pdf",4.5,4)
par(mar=c(5,4,4,1))
plot(y=holder[,1],x=holder[,2],xlim=c((min(holder[,2],0)),max(holder[,2])), 
  axes=F, xlab="Minimally meaningful BIT reward\n(percentage point increase in probability of signing)",
  ylab="Confidence level",main="BIT - ICCPR (Model 9)")
segments(y0=holder[,1],y1=rep(0,length(holder[,1])),x0=holder[,2],x1=holder[,2], lty=2)
axis(1)
axis(2,at=holder[,1],labels=round(holder[,1],3), las=2)
dev.off()


## BIT - OP1
sig <- c(.99,.95,.90,.85,.80,.75)
holder <- matrix(c(-.1907562,   -.0207325,
                   -.1483588,   -.0362798,
                   -.1346225 ,  -.0466454,
                   -.1245628 ,  -.0525725,
                   -.1148179 ,  -.0576451,
                   -.1092759 ,   -.062536),6,2,byrow=T)
holder
holder <- cbind(sig,holder[,2]*100,holder[,1]*100)

holder
  ## figure
pdf("bit-opt1.pdf",4.5,4)
par(mar=c(5,4,4,1))
plot(y=holder[,1],x=holder[,2],xlim=c((min(holder[,2],0)),max(holder[,2])), 
  axes=F, xlab="Minimally meaningful BIT reward\n(percentage point increase in probability of signing)",
  ylab="Confidence level",main="BIT - OP 1 (Model 10)")
segments(y0=holder[,1],y1=rep(0,length(holder[,1])),x0=holder[,2],x1=holder[,2], lty=2)
axis(1)
axis(2,at=holder[,1],labels=round(holder[,1],3), las=2)
dev.off()


## BIT - CAT
sig <- c(.99,.95,.90,.85,.80,.75)
holder <- matrix(c(-.0701851 ,   .0327659,
                   -.0504185 ,   .0192609,
                   -.0433453 ,   .0111535,
                   -.0383736  ,  .0072986,
                   -.0336939 ,   .0034659,
                   -.029467 ,  -.0005967),6,2,byrow=T)
holder
holder <- cbind(sig,holder[,2]*100,holder[,1]*100)

holder
  ## figure
pdf("bit-cat.pdf",4.5,4)
par(mar=c(5,4,4,1))
plot(y=holder[,1],x=holder[,2],xlim=c((min(holder[,2],0)),max(holder[,2])), 
  axes=F, xlab="Minimally meaningful BIT reward\n(percentage point increase in probability of signing)",
  ylab="Confidence level",main="BIT - CAT (Model 11)")
segments(y0=holder[,1],y1=rep(0,length(holder[,1])),x0=holder[,2],x1=holder[,2], lty=2)
axis(1)
axis(2,at=holder[,1],labels=round(holder[,1],3), las=2)
dev.off()



## BIT - art22
sig <- c(.99,.95,.90,.85,.80,.75)
holder <- matrix(c(-.0266949 ,   .2790822,
                   .0163724 ,    .233283,
                   .0255451 ,   .1903312,
                   .0327635 ,    .167697,
                   .039305  ,  .1477568,
                   .045865 ,   .1341164),6,2,byrow=T)
holder
holder <- cbind(sig,holder[,2]*100,holder[,1]*100)

holder
  ## figure
pdf("bit-art22.pdf",4.5,4)
par(mar=c(5,4,4,1))
plot(y=holder[,1],x=holder[,2],xlim=c((min(holder[,2],0)),max(holder[,2])), 
  axes=F, xlab="Minimally meaningful BIT reward\n(percentage point increase in probability of signing)",
  ylab="Confidence level",main="BIT - Art 22 (Model 12)")
segments(y0=holder[,1],y1=rep(0,length(holder[,1])),x0=holder[,2],x1=holder[,2], lty=2)
axis(1)
axis(2,at=holder[,1],labels=round(holder[,1],3), las=2)
dev.off()

setwd("..")
